import 'package:flutter/material.dart';
import '../widgets/AppColors.dart';

class FeaturesItem extends StatelessWidget {
  final Map<String, dynamic> data;
  final int pageType;

  const FeaturesItem({super.key, required this.pageType, required this.data});

  static const iconArray = [
    'assets/images/setting/repair.png',
    'assets/images/setting/message.png',
    'assets/images/setting/notice.png'
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(16.0),
      margin: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 8.0),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(8.0), // 圆角边框
        color: AppColors.cardColor, // 背景色
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      Image(image: AssetImage(iconArray[pageType])),
                      Text(
                        pageType == 2
                            ? data['noticeTitle']
                            : (pageType == 0
                                ? data['typeName'] + '故障'
                                : data['title']),
                        style: TextStyle(
                            fontSize: 16,
                            fontWeight: FontWeight.bold,
                            color: AppColors.textPrimary),
                        textAlign: TextAlign.start,
                        overflow: TextOverflow.ellipsis, // 添加溢出处理
                        maxLines: 1,
                      ),
                    ],
                  ),
                ],
              ),
              SizedBox(height: 8),
              Row(
                mainAxisAlignment: MainAxisAlignment.start, // 使内容两端对齐
                children: [
                  Text(
                    pageType == 2
                        ? data['createTime'] ?? ''
                        : (pageType == 1
                            ? data['content'] ?? ''
                            : data['updateTime'] ?? ''),
                    style:
                        TextStyle(fontSize: 13, color: AppColors.textPrimary),
                    textAlign: TextAlign.start,
                  )
                ],
              )
            ],
          ),
        ],
      ),
    );
  }
}
